<?php
/**
 * @description : Read and get a xml content.
 * @class-name  : ConfigReader. 
 * @method      : getConfig().
 * @author      : stephen.mo@hotmail.com
 * @version     : $Id , 1.0.0
 * @date        : Mar 24,2011
 */

class ConfigReader {
    const CONFIG_CACHE_TTL = 3600; //unit is second.
    private $config_file;
    private $config;
    
    /** constructor of class */
    public function __construct($file_name) {/*{{{*/
        $this->config_file = $file_name;
        $key = 'CONFIG_READER_'.$file_name;
        $config_string = apc_fetch($key);
        if (!$config_string) {
            $config_string = file_get_contents($file_name);
            apc_store($key,$config_string,self::CONFIG_CACHE_TTL);
        }
        $this->config = simplexml_load_string($config_string, 'SimpleXMLElement',LIBXML_NOCDATA);

    }/*}}}*/
    
    /** get config vars */
    public function getConfig() {/*{{{*/
        return $this->config;
    }/*}}}*/

}

?>

